<%@ page language="java" 
         contentType="text/html; charset=windows-1256"
         pageEncoding="windows-1256"
         import="LoginUtil.*"
         import="java.sql.*"
         import="java.awt.*" 
		 import="java.io.*" 
 		import="org.jfree.chart.*" 
 		import="org.jfree.chart.axis.*" 
 		import="org.jfree.chart.entity.*" 
 		import="org.jfree.chart.labels.*" 
 		import="org.jfree.chart.plot.*" 
 		import="org.jfree.chart.renderer.category.*" 
  		import="org.jfree.chart.urls.*" 
	 	import="org.jfree.data.category.*" 
	 	import="org.jfree.data.general.*" 
   %> 
 <%  User currentUser = (User) (session.getAttribute("currentSessionUser")); 
 	if(currentUser == null || currentUser.getUserType() != User.UserType.Patient)
 	{
 		response.sendRedirect("login.jsp");
 	}
%>

<%

			double[][] data = new double[4][4];
			data[0][0] = 210;
			data[0][1] = 300;
			data[0][2] = 320;
			data[0][3] = 265;
			data[1][0] = 200;
			data[1][1] = 304;
			data[1][2] = 201;
			data[1][3] = 201;
			
            CategoryDataset dataset =  DatasetUtilities.createCategoryDataset("Team ", "", data);

            JFreeChart chart = ChartFactory.createAreaChart(
                    "Area Chart", "", "Value", dataset, 
                     PlotOrientation.VERTICAL,
                    true, true, false);

            CategoryPlot plot = chart.getCategoryPlot();
            plot.setForegroundAlpha(0.5f);

            chart.setBackgroundPaint(new Color(249, 231, 236));

            try 
            {
                ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
                File file1 = new File("../webapps/jspchart/web/areachart.png");
                ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info);
            } 
            catch (Exception e) 
            {
                out.println(e);
            }
            
            ChartFrame frame1 = new ChartFrame("XYLine Chart", chart);
            frame1.setVisible(true);
            frame1.setSize(300, 300);
           
%>
   <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
   "http://www.w3.org/TR/html4/loose.dtd">

   <html>

      <head>
         <meta http-equiv="Content-Type" 
            content="text/html; charset=windows-1256">
         <title>  Welcome - Adventure Time MedSys   </title>
         <link rel="stylesheet" type="text/css" href="style.css" />
      </head>
	
      <body>

         <center>
           <div class="h0"> Welcome <%= currentUser.getFirstName() + " " + currentUser.getLastName() %> </div>
           Not <%= currentUser.getFirstName()%>? <a href="logout.jsp">Log in.</a><br><br></br>
           
           <div class="h1">Patient Weight over Time</div><br><br><br>
			<IMG SRC="areachart.png" WIDTH="600" HEIGHT="400" BORDER="0" 
         USEMAP="#chart">

           
         </center>
         
      

      </body>
	
   </html>